//
//  VisitorView.swift
//  CXWeibo
//
//  Created by 陈旭 on 16/9/11.
//  Copyright © 2016年 陈旭. All rights reserved.
//

import UIKit

class VisitorView: UIView {
    // MARK:- 快速通过xib创建的类方法
    class func visitorView() -> VisitorView{
        return NSBundle.mainBundle().loadNibNamed("VisitorView", owner: nil, options: nil).first as! VisitorView
    }
    
    // MARK:- 控件的属性
    @IBOutlet weak var rotationView: UIImageView!
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var tipLabel: UILabel!
    @IBOutlet weak var registerBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!
    
    // MARK:- 自定义函数
    func setupVisitorViewInfo(iconName: String, title: String){
        iconView.image = UIImage(named: iconName)
        tipLabel.text = title
        rotationView.hidden = true
    }
    
    ///添加转盘动画
    func addRotationAnim(){
        let rotationAnim = CABasicAnimation(keyPath: "transform.rotation.z")
        rotationAnim.fromValue = 0
        rotationAnim.toValue = M_PI * 2
        rotationAnim.repeatCount = MAXFLOAT
        rotationAnim.duration = 10
        rotationAnim.removedOnCompletion = false // 保证从其他页面重新进入本页面时，动画还在
        rotationView.layer.addAnimation(rotationAnim, forKey: nil)
    }
}
